Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = {
    setDefaults: function() {
        return {
            str: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
            num: 6,
            width: 120,
            height: 40,
            bgColor: void 0,
            fontColor: void 0,
            hasPoint: !0,
            hasLine: !0
        };
    },
    randomNum: function(t, o) {
        return Math.floor(Math.random() * (o - t) + t);
    },
    randomColor: function(t, o) {
        return "rgb(" + this.randomNum(t, o) + ", " + this.randomNum(t, o) + ", " + this.randomNum(t, o) + ")";
    },
    draw: function(t) {
        var o = this, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, n = r.str, e = r.num, a = r.width, i = r.height, l = r.bgColor, u = r.fontColor, m = r.hasPoint, s = r.hasLine, d = wx.createCanvasContext(t), h = function() {
            var t = "";
            "function" == typeof d.setTextBaseline && d.setTextBaseline("bottom"), d.setFillStyle(l || o.randomColor(180, 240)), 
            d.fillRect(0, 0, a, i);
            for (var r = 0; r < e; r++) {
                var h = (a - 10) / e * r + 10, f = o.randomNum(i / 2, i), c = o.randomNum(-45, 45), v = n[o.randomNum(0, n.length)], N = o.randomNum(16, 40), g = parseInt(i / 2);
                t += v, d.setFillStyle(u || o.randomColor(10, 100)), d.setFontSize(N > g ? g : N), 
                d.translate(h, f), d.rotate(c * Math.PI / 180), d.fillText(v, 0, 0), d.rotate(-c * Math.PI / 180), 
                d.translate(-h, -f);
            }
            if (s) for (var C = 0; C < e; C++) d.setStrokeStyle(o.randomColor(90, 180)), d.beginPath(), 
            d.moveTo(o.randomNum(0, a), o.randomNum(0, i)), d.lineTo(o.randomNum(0, a), o.randomNum(0, i)), 
            d.stroke();
            if (m) for (var b = 0; b < 10 * e; b++) d.setFillStyle(o.randomColor(0, 255)), d.beginPath(), 
            d.arc(o.randomNum(0, a), o.randomNum(0, i), 1, 0, 2 * Math.PI), d.fill();
            return t;
        };
        return {
            draw: function() {
                var t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0], o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : function() {};
                d.clearRect(0, 0, a, i);
                var r = h();
                d.draw(t, function() {
                    return o(r);
                });
            }
        };
    },
    init: function(t) {
        var o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = Object.assign({
            id: t
        }, this.setDefaults(), o);
        return this.draw(t, r);
    }
};